Skip to content

refactor(markdown): deduplicate shared helper functions#9766

Merged
dyc3 merged 2 commits intobiomejs:mainfrom
jfmcdowell:refactor/markdown-deduplicate-helpers
Apr 1, 2026
Merged

refactor(markdown): deduplicate shared helper functions#9766
dyc3 merged 2 commits intobiomejs:mainfrom
jfmcdowell:refactor/markdown-deduplicate-helpers

Conversation

@jfmcdowell
Copy link
Copy Markdown
Contributor

Note

This PR was created with AI assistance (Claude Code).

Summary

Extract two duplicated helper functions into shared pub(crate) definitions:

  • is_whitespace_only: was identical in list.rs, quote.rs, and mod.rs. Now lives once in syntax/mod.rs.
  • find_line_start: was identical in token_source.rs and fenced_code_block.rs. Now lives once in token_source.rs.

No behavior change.

Test Plan

  • just test-crate biome_markdown_parser — all passed
  • just test-markdown-conformance — 652/652
  • just f
  • just l

Docs

N/A.

Extract `is_whitespace_only` as `pub(crate)` in `syntax/mod.rs` and
remove identical copies from `list.rs` and `quote.rs`.

Extract `find_line_start` as `pub(crate)` in `token_source.rs` and
remove the identical copy from `fenced_code_block.rs`.
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 1, 2026

⚠️ No Changeset found

Latest commit: 7180db4

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions github-actions bot added A-Parser Area: parser L-Markdown Language: Markdown labels Apr 1, 2026
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Apr 1, 2026

Merging this PR will not alter performance

✅ 28 untouched benchmarks
⏩ 228 skipped benchmarks1


Comparing jfmcdowell:refactor/markdown-deduplicate-helpers (7180db4) with main (716e4e1)

Open in CodSpeed

Footnotes

  1. 228 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@jfmcdowell jfmcdowell marked this pull request as ready for review April 1, 2026 17:51
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 1, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 7523a799-c1cf-4762-ac83-ce7b4e9e22cd

📥 Commits

Reviewing files that changed from the base of the PR and between 20e2000 and 7180db4.

📒 Files selected for processing (1)
  • crates/biome_markdown_parser/src/syntax/list.rs

Walkthrough

This PR centralises two previously duplicated helpers in the markdown parser by making find_line_start (from token_source.rs) and is_whitespace_only (from syntax/mod.rs) pub(crate) and updating fenced_code_block.rs, list.rs, and quote.rs to import and use those shared implementations instead of local copies. No public API signatures were changed.

Possibly related PRs

  • PR #9730: Modifies fenced code block closing-fence detection and virtual_line_start handling, using the same consolidated find_line_start logic.
  • PR #9740: Adjusts HTML block parsing around virtual_line_start validation; shares the same helper-consolidation pattern for line-start logic.

Suggested reviewers

  • dyc3
  • ematipico
🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarises the main change: deduplicating shared helper functions across the markdown parser modules.
Description check ✅ Passed The description clearly relates to the changeset, detailing which functions were deduplicated, where they now live, and providing test coverage evidence.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@jfmcdowell jfmcdowell force-pushed the refactor/markdown-deduplicate-helpers branch from 49d028c to 7180db4 Compare April 1, 2026 17:59
@dyc3 dyc3 merged commit 3ba5325 into biomejs:main Apr 1, 2026
15 checks passed
@jfmcdowell jfmcdowell deleted the refactor/markdown-deduplicate-helpers branch April 13, 2026 12:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Parser Area: parser L-Markdown Language: Markdown

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants